<?php
namespace app\common\model;

use think\Model;

class UniqueViewLog extends Base
{
    protected $table = 'unique_view_logs';

    public function getCreateTimeLabelAttr($value, $data)
    {
        if (empty($data['create_time'])) {
            return '';
        }

        return date('Y-m-d H:i:s', $data['create_time']);
    }

    public function getChannelNameAttr($value, $data)
    {
        $channel = Channel::get(array('id' => $data['channel_id']));
        if (!empty($channel)) {
            return $channel['name'];
        }

        return '';
    }

    public function getIpLabelAttr($value, $data)
    {
        if (is_numeric($data['ip'])) {
            return long2ip(intval($data['ip']));
        }

        return '';
    }

}